﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BaiduFanyi.Config
{
    /// <summary>
    /// 常用类型
    /// </summary>
    public class CommonUseType
    {
        /// <summary>
        /// 类型名称
        /// </summary>
        public string Name="";

        /// <summary>
        /// 使用次数
        /// </summary>
        public int UseTimes=0;

        public CommonUseType()
        {

        }

        public CommonUseType(string name)
        {
            Name = name;
        }

        public CommonUseType(KeyValuePair<string, int> keyValuePair)
        {
            Name = keyValuePair.Key;
            UseTimes = keyValuePair.Value;
        }
    }

    public class CommonUseTypeCompare : IComparer<CommonUseType>
    {
        public int Compare(CommonUseType x, CommonUseType y)
        {
            if (x==null&&y==null)
            {
                return 0;
            }

            if (x==null)
            {
                return -1;
            }

            if (y==null)
            {
                return 1;
            }
            return x.UseTimes - y.UseTimes;
        }
    }
}
